//
//  JYTSchoolTableViewCell.m
//  JYT_IOS
//
//  Created by nxa-tankeke on 16/12/28.
//  Copyright © 2016年 nxa-yuanguoxiang. All rights reserved.
//

#import "JYTSchoolTableViewCell.h"
#import "JYTStars.h"
#import "School.h"
#import <UIImageView+WebCache.h>

@interface JYTSchoolTableViewCell()
@property (weak, nonatomic) IBOutlet UIImageView *schoolImageView;

@property (weak, nonatomic) IBOutlet UILabel *schoolName;

@property (weak, nonatomic) IBOutlet UILabel *sCount;
@property (weak, nonatomic) IBOutlet UILabel *allowMeet;

@property (weak, nonatomic) IBOutlet UILabel *price;


@property (weak, nonatomic) IBOutlet UIImageView *oneLevel;
@property (weak, nonatomic) IBOutlet UIImageView *twoLevel;
@property (weak, nonatomic) IBOutlet UIImageView *threeLevel;
@property (weak, nonatomic) IBOutlet UIImageView *fourLevel;
@property (weak, nonatomic) IBOutlet UIImageView *fiveLevel;

@end

@implementation JYTSchoolTableViewCell


+(instancetype)cell
{
    
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] firstObject];
}

-(void)setSchool:(School *)school
{
    _school = school;
    
    NSString *imgURL = school.logoUrl;
    if (imgURL) {
        [self.schoolImageView sd_setImageWithURL:[NSURL URLWithString:imgURL] placeholderImage:[UIImage imageNamed:@"02驾校查询_22"]];
    } else {
        [self.schoolImageView setImage:[UIImage imageNamed:@"02驾校查询_22"]];
    }
    
    [self.schoolName setText:school.drivingSchoolName];
    
    
    [self.sCount setText:[NSString stringWithFormat:@"学员数: %@",school.studentNum]];
    
    
    NSString *isShuttle =  school.isShuttle;
    if ([isShuttle isEqualToString:@"1"]) {
        [self.allowMeet setText:[NSString stringWithFormat:@"是否接送: %@",@"是"]];
    } else {
        [self.allowMeet setText:[NSString stringWithFormat:@"是否接送: %@",@"否"]];
    }
    
    NSString *price =  school.price;
    NSString *newPrice = [NSString stringWithFormat:@"¥%@起",price];
    [self.price setText:newPrice];
    
    NSString *starLevel = school.starLevel;
    if ([starLevel isEqualToString:@"1"]) {
        [self.oneLevel setHidden:YES];
        
    } else if([starLevel isEqualToString:@"2"]) {
        [self.oneLevel setHidden:YES];
        [self.twoLevel setHidden:YES];
        
    } else if([starLevel isEqualToString:@"3"]) {
        [self.oneLevel setHidden:YES];
        [self.twoLevel setHidden:YES];
        [self.threeLevel setHidden:YES];
        
    } else if([starLevel isEqualToString:@"4"]) {
        [self.oneLevel setHidden:YES];
        [self.twoLevel setHidden:YES];
        [self.threeLevel setHidden:YES];
        [self.fourLevel setHidden:YES];
        
    } else if([starLevel isEqualToString:@"5"]) {
        [self.oneLevel setHidden:YES];
        [self.twoLevel setHidden:YES];
        [self.threeLevel setHidden:YES];
        [self.fourLevel setHidden:YES];
        [self.fiveLevel setHidden:YES];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
  
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
